#! /usr/bin/python
# -*- coding: cp1250 -*-
# mvdt2.py

import time, shutil, sys, os
import pepe.p_oslevel.basic as wai

whereami = wai.wai()

#itn = lambda : time.strftime ("%Y-%m-%dT%H%M%S_", time.localtime()) # iso time now
#itn = lambda : time.strftime ("\%Y%m%d-%H%M_", time.localtime()) # iso time now
itn = lambda : time.strftime ("%Y-%m-%d_%H%M_", time.localtime()) # iso time now

def mvdt2(sargv):
    ''' This is a modified mvdt.py.
        Purpose: File or folder will be moved to new location with ISO timestamp in front of the orginal name.
        Syntax: mvdt2.py R:\prague-faa\%cid%\output\Output
                - moves Output folder to R:\prague-faa\%cid%\output\20100118-1803_Output
    '''
    p,f  = os.path.split(sargv[1]) # path, file
    #pf = whereami + sargv[1] # path + file
    p = p + "\\"
    err = '''
    Syntax: mvdt2 <file/folder>
    or file/folder %s was not found in path %s
    '''
    if len(sargv) == 2:
        a = sargv[1]
        b = "%s%s%s" % (p, itn(), f)
        """
        print '*'*20
        print a
        print b
        print '*'*20
        """
        shutil.move(a, b)
    else:
        print err % (f,p)
	
if __name__ == '__main__':
    ''' '''
    #print whereami
    #print sys.argv
    mvdt2(sys.argv)


